package com.ohc.leetcode.数组;

import java.util.Arrays;

/**
 * https://leetcode-cn.com/problems/two-sum/
 */
public class 两数之和1 {

    public static int[] twoSum(int[] nums, int target) {
        int num = 0;
        int[] ints = new int[2];
        for (int i = 0; i < nums.length; i++) {
            num = nums[i];
            for (int j = i + 1; j < nums.length; j++) {
                if (num + nums[j] == target) {

                    ints[0] = i;
                    ints[1] = j;
                }
            }
        }
        return ints;
    }

    public static void main(String[] args) {
        int[] nums = new int[]{2, 7, 11, 15};
        int target = 13;
        int[] ints = twoSum(nums, target);
        for (int i = 0; i < ints.length; i++) {
            System.out.println("ints[i] = " + ints[i]);
        }
    }
}
